<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="../01.getting-started/demo.css">
    <title>父子组件之间的关系</title>
    <script src="https://unpkg.com/vue/dist/vue.js"></script>
</head>
<body>

<div id="app">
    <table>
        <tr>
            <th colspan="3">父组件数据</th>
        </tr>
        <tr>
            <td>姓名</td>
            <td>{{ name }}</td>
            <td><input type="text" v-model="name"/></td>
        </tr>
        <tr>
            <td>年龄</td>
            <td>{{ age }}</td>
            <td><input type="text" v-model="age"/></td>
        </tr>
    </table>

    <sub-component v-bind:user-name="name" v-bind:user-age="age"></sub-component>
</div>

<template id="sub">
    <table>
        <tr>
            <th colspan="3">子组件数据</th>
        </tr>
        <tr>
            <td>姓名</td>
            <td>{{ userName }}</td>
            <td><input type="text" v-model="userName"/></td>
        </tr>
        <tr>
            <td>年龄</td>
            <td>{{ userAge }}</td>
            <td><input type="text" v-model="userAge"/></td>
        </tr>
    </table>
</template>
<script>
    new Vue({
        el: '#app',
        data: {
            name: '张三丰',
            age: 122
        },
        components: {
            'sub-component': {
                template: '#sub',
                props: ['userName', 'userAge']
            }
        }
    });
</script>
</body>
</html>